/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Andres
 */
@Entity
@Table(name = "SOLICITUDINSUMO", catalog = "", schema = "PROYECTO")
@NamedQueries({
    @NamedQuery(name = "Solicitudinsumo.findAll", query = "SELECT s FROM Solicitudinsumo s"),
    @NamedQuery(name = "Solicitudinsumo.findByCantidad", query = "SELECT s FROM Solicitudinsumo s WHERE s.cantidad = :cantidad"),
    @NamedQuery(name = "Solicitudinsumo.findBySolicitudIdsolicitud", query = "SELECT s FROM Solicitudinsumo s WHERE s.solicitudinsumoPK.solicitudIdsolicitud = :solicitudIdsolicitud"),
    @NamedQuery(name = "Solicitudinsumo.findByInsumoIdinsumo", query = "SELECT s FROM Solicitudinsumo s WHERE s.solicitudinsumoPK.insumoIdinsumo = :insumoIdinsumo")})
public class Solicitudinsumo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected SolicitudinsumoPK solicitudinsumoPK;
    @Basic(optional = false)
    @Column(name = "CANTIDAD", nullable = false)
    private int cantidad;
    @JoinColumn(name = "SOLICITUD_IDSOLICITUD", referencedColumnName = "IDSOLICITUD", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Solicitud solicitud;
    @JoinColumn(name = "INSUMO_IDINSUMO", referencedColumnName = "IDINSUMO", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Insumo insumo;

    public Solicitudinsumo() {
    }

    public Solicitudinsumo(SolicitudinsumoPK solicitudinsumoPK) {
        this.solicitudinsumoPK = solicitudinsumoPK;
    }

    public Solicitudinsumo(SolicitudinsumoPK solicitudinsumoPK, int cantidad) {
        this.solicitudinsumoPK = solicitudinsumoPK;
        this.cantidad = cantidad;
    }

    public Solicitudinsumo(int solicitudIdsolicitud, int insumoIdinsumo) {
        this.solicitudinsumoPK = new SolicitudinsumoPK(solicitudIdsolicitud, insumoIdinsumo);
    }

    public SolicitudinsumoPK getSolicitudinsumoPK() {
        return solicitudinsumoPK;
    }

    public void setSolicitudinsumoPK(SolicitudinsumoPK solicitudinsumoPK) {
        this.solicitudinsumoPK = solicitudinsumoPK;
    }

    public int getCantidad() {
        return cantidad;
    }

    public void setCantidad(int cantidad) {
        this.cantidad = cantidad;
    }

    public Solicitud getSolicitud() {
        return solicitud;
    }

    public void setSolicitud(Solicitud solicitud) {
        this.solicitud = solicitud;
    }

    public Insumo getInsumo() {
        return insumo;
    }

    public void setInsumo(Insumo insumo) {
        this.insumo = insumo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (solicitudinsumoPK != null ? solicitudinsumoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Solicitudinsumo)) {
            return false;
        }
        Solicitudinsumo other = (Solicitudinsumo) object;
        if ((this.solicitudinsumoPK == null && other.solicitudinsumoPK != null) || (this.solicitudinsumoPK != null && !this.solicitudinsumoPK.equals(other.solicitudinsumoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Solicitudinsumo[solicitudinsumoPK=" + solicitudinsumoPK + "]";
    }

}
